<template>
  <div class="repayPlan">
    <!-- <p>{{personalInfoData}}</p> -->
    <el-form inline label-width="100px" label-position="left">
      <el-form-item label="贷款合同号:">
        <el-input v-model="dkhth" placeholder="请输入贷款合同号："></el-input>
      </el-form-item>
      <el-form-item label="证件号码:">
        <el-input v-model="idNo" placeholder="请输入证件号码"></el-input>
      </el-form-item>
      <el-form-item label="借据号:">
        <el-input v-model="loanNo" placeholder="请输入借据号"></el-input>
      </el-form-item>
      <el-form-item label="客户名称:">
        <el-input v-model="custName" placeholder="请输入客户名称"></el-input>
      </el-form-item>
      <el-row style="float: right; width: 20%">
        <el-col :span="12">
          <el-form-item style="padding-top: 40px">
            <el-button type="primary" @click="queryInfo" size="medium"
              >查询</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item style="padding-top: 40px">
            <el-button type="primary" @click="restAll" size="medium"
              >重置</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- 还款信息 -->
    <el-table
      :data="repayData"
      title="还款信息"
      border
      height="300"
      stripe="true"
      style="width: 100%"
      @cell-click="showRepayDialog"
    >
      <el-table-column type="selection" :selectable="selectable" />
      <el-table-column
        prop="contNo"
        label="贷款合同号"
        width="120"
        align="center"
      />
      <el-table-column
        prop="loanNo"
        label="借据号"
        width="120"
        align="center"
      />
      <el-table-column
        prop="idNo"
        label="证件号码"
        width="120"
        align="center"
      />
      <el-table-column
        prop="custName"
        label="客户名称"
        width="120"
        align="center"
      />
      <el-table-column
        prop="applyTnr"
        label="贷款期限"
        width="120"
        align="center"
      />
      <el-table-column
        prop="loanTyp"
        label="贷款品种"
        width="120"
        align="center"
      />
      <el-table-column prop="loanCcy" label="币种" width="80" align="center" />
      <el-table-column
        prop="origPrcped"
        label="发放金额"
        width="120"
        align="center"
      />
      <el-table-column
        prop="loanOsPrcp"
        label="剩余本金"
        width="120"
        align="center"
      />
      <el-table-column
        prop="loanActvDt"
        label="放款日期"
        width="120"
        align="center"
      />
      <el-table-column
        prop="appOrigin"
        label="业务端来源"
        width="120"
        align="center"
      />
      <el-table-column
        prop="isCompensation"
        label="是否代偿"
        width="120"
        align="center"
      />
      <el-table-column
        prop="acctNo"
        label="还款卡号"
        width="120"
        align="center"
      />
      <el-table-column
        prop="acctBankCde"
        label="开户行"
        width="120"
        align="center"
      />
      <el-table-column
        prop="managerCde"
        label="管户经理工号"
        width="120"
        align="center"
      />
      <el-table-column
        prop="managerName"
        label="管户经理姓名"
        width="120"
        align="center"
      />
      <el-table-column
        prop="managementBch"
        label="管户机构"
        width="120"
        align="center"
      />
      <el-table-column
        prop="loanPmGrd"
        label="五级分类"
        width="120"
        align="center"
      />
      <el-table-column
        prop="innerLoanNo"
        label="借据号—湖消"
        width="120"
        align="center"
      />
      <el-table-column
        prop="thirdInnerLoanNo"
        label="借据号—合作资金"
        width="120"
        align="center"
      />
    </el-table>

    <!-- 还款计划 & 贷款信息 页面 -->
    <el-dialog
      title="还款计划 & 贷款信息"
      :visible.sync="repayDialogVisible"
      :before-close="handleRepayDialogClose"
      width="80%"
      top="4vh"
    >
      <div>
        <el-tabs type="border-card">
          <el-tab-pane label="还款计划">
            <div class="repayPlan">
              <el-table
                :data="repayPlanData"
                title="还款计划"
                border
                height="250"
                stripe="true"
                style="width: 100%"
              >
                <el-table-column label="客户姓名" width="120" align="center">
                  <el-table-column
                    label="期号"
                    prop="perdNo"
                    width="120"
                    align="center"
                  />
                </el-table-column>
                <el-table-column
                  :label="paramsData.custName"
                  width="120"
                  align="center"
                >
                  <el-table-column
                    label="到期日"
                    prop="dueDt"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="期供金额"
                    prop="psInstmAmt"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="本金"
                    prop="psPrcpAmt"
                    width="120"
                    align="center"
                  />
                </el-table-column>
                <el-table-column label="借据号" width="120" align="center">
                  <el-table-column
                    label="利息"
                    prop="psNormIntAmt"
                    width="120"
                    align="center"
                  />
                </el-table-column>
                <el-table-column
                  :label="paramsData.loanNo"
                  width="120"
                  align="center"
                >
                  <el-table-column
                    label="罚息/复利"
                    prop="setlOdIntAmt_psCommOdInt"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="剩余本金"
                    prop="psRemPrcp"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="已还本金"
                    prop="setlPrcp"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="已还利息"
                    prop="setlNormInt"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="已还罚息/复利"
                    prop="repaidInterest_Compound"
                    width="120"
                    align="center"
                  />
                </el-table-column>
                <el-table-column
                  label="当前时间"
                  prop=""
                  width="120"
                  align="center"
                >
                  <el-table-column
                    label="应还总额"
                    prop="psInstmAmt"
                    width="120"
                    align="center"
                  />
                </el-table-column>
                <el-table-column
                  :label="paramsData.currentDate"
                  width="120"
                  align="center"
                  label-style="{color: 'black'}"
                >
                  <el-table-column
                    label="已还总额"
                    prop="setlSumAmt"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="应还费用"
                    prop="psInstmFee"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="已还费用"
                    prop="setlFeeAmt"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="可抵扣金额"
                    prop="kdkje"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="已抵扣金额"
                    prop="ydkje"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="息费减免"
                    prop="intFeeReduction"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="结清标志"
                    prop="setlInd"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="逾期标志"
                    prop="psOdInd"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="结清日期"
                    prop="settleTime"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="结清天数"
                    prop="jqts"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="是否延期"
                    prop="fxorfl"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    label="偿还且债权保留"
                    prop="sybj"
                    width="120"
                    align="center"
                  />
                </el-table-column>
              </el-table>
              <div style="height: 80px; padding-top: 10px">
                <el-button
                  type="primary"
                  @click="leadOut"
                  size="large"
                  style="float: right"
                  >导出</el-button
                >
                <el-button
                  type="primary"
                  @click="handleRepayDialogClose"
                  size="large"
                  style="float: right"
                  >关闭</el-button
                >
              </div>
            </div>
          </el-tab-pane>

          <el-tab-pane label="贷款信息">
            <div class="loanInfo">
              <div style="height: 320px">
                <span style="color: black; font-size: 20px">基本信息</span>
                <el-divider />
                <el-row :gutter="30" :data="loanData">
                  <el-col
                    class="mb5"
                    :span="item.span"
                    v-for="(item, index) in loanOption.column"
                    :key="index"
                  >
                    <span
                      style="
                        width: 110px;
                        display: inline-block;
                        text-align: left;
                      "
                      >{{ item.label }}:</span
                    >
                    <span>{{ item | dataDicTrans(loanData) }}</span>
                  </el-col>
                </el-row>
              </div>

              <span style="color: black; font-size: 20px; padding-top: 20px"
                >利率信息</span
              >
              <el-divider />
              <div style="height: 180px">
                <el-row :gutter="30" :data="interestRateData">
                  <el-col
                    class="mb5"
                    :span="item.span"
                    v-for="(item, index) in interestRateOption.column"
                    :key="index"
                  >
                    <span
                      style="
                        width: 120px;
                        display: inline-block;
                        text-align: right;
                      "
                      >{{ item.label }}:</span
                    >

                    <span>{{ item | dataDicTrans(data) }}</span>
                  </el-col>
                </el-row>
              </div>

              <span style="color: black; font-size: 20px">还款信息</span>
              <el-divider />
              <div style="height: 130px">
                <el-row :gutter="30" :data="repayMentData">
                  <el-col
                    class="mb5"
                    :span="item.span"
                    v-for="(item, index) in repayMentOption.column"
                    :key="index"
                  >
                    <span
                      style="
                        width: 120px;
                        display: inline-block;
                        text-align: right;
                      "
                      >{{ item.label }}:</span
                    >

                    <span>{{ item | dataDicTrans(data) }}</span>
                  </el-col>
                </el-row>
              </div>

              <span style="color: black; font-size: 20px">还款策略信息</span>
              <div style="padding-top: 20px">
                <el-table
                  :data="repayMentStrategy"
                  title="还款策略信息"
                  border
                  stripe="true"
                  style="width: 100%"
                >
                  <!-- <el-table-column type="selection" :selectable="selectable" /> -->
                  <el-table-column
                    prop="jdh"
                    label="阶段号"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="qsq"
                    label="起始期"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="jzq"
                    label="截止期"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="hklx"
                    label="还款类型"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="hkfs"
                    label="还款方式"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="jzll"
                    label="基准利率"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="llfdbl"
                    label="利率浮动比例"
                    width="120"
                    align="center"
                  />
                  <el-table-column
                    prop="zxnll"
                    label="执行年利率"
                    width="120"
                    align="center"
                  />
                </el-table>
                <div style="height: 80px; padding-top: 30px">
                  <el-button
                    type="primary"
                    @click="handleRepayDialogClose"
                    size="large"
                    style="float: right"
                    >关闭</el-button
                  >
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-dialog>
  </div>
</template>

  <script>
import Axios from "axios";
import { dataDicTrans } from "@/api/bankBiz/loss/loss";
import {
  queryInfoCMIS100001,
  queryInfoCMIS100003,
  queryInfoCMIS100098,
} from "@/api/hubeixiaojin/queryInfo";

export default {
  name: "repayPlan",
  props: ["personalInfoData"],
  data() {
    return {
      refreshKey: 0, // 新增一个状态变量
      objForm: {},
      dkhth: "",
      idNo: "",
      loanNo: "",
      custName: "",
      currentDate: "",
      //repayData:[{'contNo':'HT1000002078103010035079','custName':'drx','loanNo':'4567899','idNo':'500227****5217'},{'contNo':'2222','custName':'drx2'},{'contNo':'cs'}],
      repayData: [],
      //repayPlanData:[{'psInstmAmt':'1000','odIntRate':'11111'},{'psInstmAmt':'2000','odIntRate':'22222'}],
      repayPlanData: [],
      repayPlan_loanNo: "",
      repayPlan_custName: "",
      paramsData: {},
      repayDialogVisible: false,
      loanOption: {
        title: "基本信息",
        column: [
          {
            prop: "contNo",
            label: "贷款合同号",
            span: 20,
          },
          {
            prop: "loanNo",
            label: "借据号",
            span: 10,
          },
          {
            prop: "custName",
            label: "借款人姓名",
            span: 20,
          },
          {
            prop: "idNo",
            label: "借款人证件号码",
            span: 20,
          },
          {
            prop: "idTyp",
            label: "借款人证件类型",
            span: 10,
          },
          {
            prop: "dkzt",
            label: "贷款状态",
            span: 10,
          },
          {
            prop: "origPrcped",
            label: "发放金额",
            span: 10,
          },
          {
            prop: "loanOsPrcp",
            label: "剩余本金",
            span: 10,
          },
          {
            prop: "loanCcy",
            label: "币种",
            span: 10,
          },
          {
            prop: "applyTnr",
            label: "贷款期限",
            span: 10,
          },

          {
            prop: "loanActvDt",
            label: "放款日期",
            span: 20,
          },
        ],
      },
      loanData: {},
      interestRateOption: {
        title: "利率信息",
        column: [
          {
            prop: "mtdMode",
            label: "利率模式",
            span: 10,
          },
          {
            prop: "jbll",
            label: "基本利率",
            span: 10,
          },
          {
            prop: "jbll",
            label: "利率浮动比例",
            span: 10,
          },
          {
            prop: "loanIntRate",
            label: "执行利率",
            span: 10,
          },
          {
            prop: "fxfdbl",
            label: "罚息浮动比例",
            span: 10,
          },
          {
            prop: "odIntRate",
            label: "罚息利率",
            span: 10,
          },
          {
            prop: "nyfdbl",
            label: "挪用浮动比例",
            span: 10,
          },
          {
            prop: "nybl",
            label: "挪用比例",
            span: 10,
          },
        ],
      },
      interestRateData: {},
      repayMentOption: {
        title: "还款信息",
        column: [
          {
            prop: "mtdCode",
            label: "还款方式",
            span: 10,
          },
          {
            prop: "loanFreq",
            label: "还款间隔",
            span: 10,
          },
          {
            prop: "hkjgdw",
            label: "还款间隔单位",
            span: 10,
          },
          {
            prop: "hkqx",
            label: "还款期限",
            span: 10,
          },
          {
            prop: "qxr",
            label: "起息日",
            span: 10,
          },
          {
            prop: "zhdqr",
            label: "最后到期日",
            span: 10,
          },
        ],
      },
      repayMentData: {},
      repayMentStrategy: [],
    };
  },

  created() {
    this.currentDate = this.getDate();
    var zjhm = sessionStorage.getItem("idNo"); //身份证号
    console.log("还款信息查询模块初始化：", zjhm);
    this.queryInfo(zjhm);
  },

  watch: {
    $route: function (to, from) {
      // console.log("监听【还款信息模块】route变化");
      this.$destroy();
    },
  },

  methods: {
    queryInfo(str) {
      let self = this;
      self.repayData = [];
      //   var param = str;
      //   if (this.idNo.length > 0) {
      //     param = this.idNo;str
      //   }
      var param = {
        contNo: this.dkhth,
        idNo: typeof str === "string" ? str : this.idNo,
        loanNo: this.loanNo,
        custName: this.custName,
      };

      //   if (param.length > 0) {
      //获取申请流水号列表
      var applSeqList = [];
      queryInfoCMIS100098(param)
        .then((res) => {
          if (res.retCode == "200") {
            applSeqList = res.data;
            this.xiangxixinxi(applSeqList);
          } else {
            self.repayData = [];
            console.log("调用CMIS100098接口失败:");
          }
        })
        .catch((err) => {
          console.log("调用CMIS100098接口异常:");
          console.log(err);
        });

      //   } else {
      //     console.log("还款信息查询 异常：无身份证号");
      //     window.globalUiKit.notify("提示", "请填写身份证号", "info");
      //   }
    },

    xiangxixinxi(applSeqList) {
      if (applSeqList.length > 0) {
        queryInfoCMIS100001(applSeqList)
          .then((res2) => {
            console.log("贷款合同详情:", res2.data);
            if (res2.retCode == "200" || res2.retCode == 200) {
              // console.log("查询成功,赋值repayData");
              this.repayData = res2.data;
                this.$set(this, 'repayData', res2.data);
              console.log("this.repayData==", this.repayData[0].custName);
            } else {
              this.repayData = [];
              // console.log("调用CMIS100001接口失败:");
              window.globalUiKit.notify("提示", "未查询到客户信息", "info");
            }
          })
          .catch((err) => {
            this.repayData = [];
            window.globalUiKit.notify("提示", "未查询到客户信息", "error");
            // console.log("调用CMIS100001接口异常:");
            // console.log(err);
          });
      } else {
        self.repayData = [];
        window.globalUiKit.notify(
          "提示",
          "未查询到客户信息，请联系管理员",
          "info"
        );
      }
    },

    //展示还款计划&贷款信息页面
    showRepayDialog(row, column, cell) {
      // console.log(row)
      // console.log(column)
      // console.log(cell)
      //判断点击的单元格是否贷款合同号：
      if (column.property === "contNo") {
        this.repayDialogVisible = true;
        //还款计划列表：
        this.paramsData.custName = row.custName;
        this.paramsData.loanNo = row.loanNo;
        this.paramsData.currentDate = this.getDate();
        //贷款信息列表：
        this.loanData.loanNo = row.loanNo; //借据号
        this.loanData.contNo = row.contNo; //贷款合同号
        this.loanData.custName = row.custName; //借款人姓名
        this.loanData.idTyp = row.idTyp; //借款人证件类型
        this.loanData.idNo = row.idNo; //借款人证件号码
        this.loanData.loanCcy = row.loanCcy; //币种
        this.loanData.origPrcped = row.origPrcped; //发放金额
        this.loanData.loanOsPrcp = row.loanOsPrcp; //剩余本金
        this.loanData.applyTnr = row.applyTnr; //贷款期限
        this.loanData.loanActvDt = row.loanActvDt; //放款日期
        this.loanData.dkzt = row.inStsDesc; //贷款状态
        //利率信息列表:
        this.interestRateData.mtdMode = row.mtdMode; //利率模式
        this.interestRateData.jbll = ""; //基本利率
        this.interestRateData.llfdbl = ""; //利率浮动比例
        this.interestRateData.loanIntRate = row.loanIntRate; //执行利率
        this.interestRateData.fxfdbl = ""; //罚息浮动比例
        this.interestRateData.nyfdbl = ""; //挪用浮动比例
        this.interestRateData.nybl = ""; //挪用比例
        //还款信息列表：
        this.repayMentData.mtdCde = row.mtdCde; //还款方式
        this.repayMentData.loanFreq = row.loanFreq; //还款间隔
        this.repayMentData.hkjgdw = ""; //还款间隔单位
        this.repayMentData.hkqx = ""; //还款期限
        this.repayMentData.qxr = ""; //起息日
        this.repayMentData.zhdqr = ""; //最后到期日
        this.repayMentData.settleTime = row.settleTime; //结清日期

        //还款策略信息列表：
        this.repayMentStrategy.jdh = ""; //阶段号
        this.repayMentStrategy.qsq = ""; //起始期
        this.repayMentStrategy.jzq = ""; //截止期
        this.repayMentStrategy.mtdCde = row.mtdCde; //还款方式
        this.repayMentStrategy.hklx = ""; //还款类型
        this.repayMentStrategy.jzll = ""; //基准利率
        this.repayMentStrategy.llfdbl = ""; //利率浮动比例
        this.repayMentStrategy.loanIntRate = row.loanIntRate; //执行年利率
        //调用CMIS100003接口查询还款计划列表
        var params = {};
        params.loanNo = row.loanNo;
        // params.userId = Constants.Agent.agentId//操作用户
        // params.userName = Constants.Agent.agentName//用户名称
        // params.userOrgNo = Constants.Agent.deptGroupCode//用户机构
        params.userId = ""; //操作用户
        params.userName = ""; //用户名称
        params.userOrgNo = ""; //用户机构

        params.enqTyp = "All"; //查询类型
        // console.log("测试测试");
        // console.log(params);
        queryInfoCMIS100003(params)
          .then((res) => {
            console.log("调用核心CMIS100003接口查询还款信息");
            console.log(res);
            if (res.retCode === "200") {
              //还款计划列表：
              var ListData = res.data;
              // 遍历repayPlanData 并进行相关计算
              ListData.forEach((item) => {
                // 已还罚息/复利 = 已还逾期利息/已还复利
                if (item.setlCommOdInt !== "0.00") {
                  // 防止除以0的情况
                  item.setlOdIntAmt_setlCommOdInt = (
                    parseFloat(item.setlOdIntAmt) /
                    parseFloat(item.setlCommOdInt)
                  ).toFixed(2);
                } else {
                  item.repaidInterest_Compound = parseFloat("0.00"); //默认0
                }
                // 罚息/复利 = 逾期利息/复利
                if (item.psCommOdInt !== "0.00") {
                  // 防止除以0的情况
                  item.setlOdIntAmt_psCommOdInt = (
                    parseFloat(item.setlOdIntAmt) / parseFloat(item.psCommOdInt)
                  ).toFixed(2);
                } else {
                  item.setlOdIntAmt_psCommOdInt = parseFloat("0.00"); //默认0
                }
                //应还费用 = 违约金+滞纳金+账号管理费+期供金额
                item.psInstmFee = (
                  parseFloat(item.penalFeeAmt) +
                  parseFloat(item.lateFeeAmt) +
                  parseFloat(item.acctFeeAmt) +
                  parseFloat(item.psInstmAmt)
                ).toFixed(2);
                //已还总额 = 已还本金+已还利息+已还逾期利息+已还复利+已还费用金额+已收违约金+已收滞纳金+已收账号管理费+期供金额
                item.setlSumAmt = (
                  parseFloat(item.setlPrcp) +
                  parseFloat(item.setlNormInt) +
                  parseFloat(item.setlOdIntAmt) +
                  parseFloat(item.setlCommOdInt) +
                  parseFloat(item.setlFeeAmt) +
                  parseFloat(item.setlPenalFeeAmt) +
                  parseFloat(item.setlLateFeeAmt) +
                  parseFloat(item.setlAcctFeeAmt) +
                  parseFloat(item.psInstmAmt)
                ).toFixed(2);
                //可抵扣金额(待业务确认)
                item.kdkje = parseFloat("0.00"); //默认0
                //已抵扣金额(待业务确认)
                item.ydkje = parseFloat("0.00"); //默认0
                //息费减免 = 减免正常利息 + 减免逾期利息 + 减免复利
                item.intFeeReduction = (
                  parseFloat(item.psWvNmInt) +
                  parseFloat(item.psWvOdInt) +
                  parseFloat(item.psWvCommInt)
                ).toFixed(2);
              });
              this.repayPlanData = ListData;

              //利率信息列表:
              this.interestRateData.odIntRate = res.data[0].odIntRate; //罚息利率
            } else {
              console.log("调用CMIS100003接口查询还款计划列表失败,res:");
              window.globalUiKit.notify(
                "提示",
                "未查询到还款计划,请联系管理员",
                "info"
              );
            }
          })
          .catch((err) => {
            console.log("调用CMIS100003接口发生异常" + err);
            window.globalUiKit.notify(
              "提示",
              "未查询到还款计划,请联系管理员",
              "error"
            );
          });
      }
    },

    restAll() {
      console.log("重置【还款信息查询】页面数据");
      this.repayPlanData = [];
      this.interestRateData = [];
      this.paramsData = [];
      this.loanData = [];
      this.repayMentData = [];
      this.repayMentStrategy = [];
      this.repayData = [];
    },
    getDate() {
      var currentDate = new Date();
      var year = currentDate.getFullYear();
      var month = currentDate.getMonth() + 1; // 月份从0开始，所以需要加1
      var day = currentDate.getDate();
      var date = year + "-" + month + "-" + day;

      return date;
    },

    custName({ row, column, rowIndex, columnIndex }) {
      // 在此处根据特定条件返回对应的类名
      return "custName";
    },

    //导出还款计划：
    leadOut() {
      console.log("导出还款计划：");

      var reqData = {};
      var headRow = {}; //body子信息
      // var head = {}   //head信息
      // var body = {}   //body信息
      // var targetbody = {}
      // var request = {}

      // request.head = head
      // //body
      // body.repayPlanData = this.repayPlanData

      // request.body = body
      // targetbody.request = request
      // reqData.targetbody = targetbody
      // reqData.targetSysCode = "esb"
      // reqData.actionCode = "query"
      // reqData.targetRoute = "excelExport"

      headRow.custName = this.paramsData.custName;
      headRow.loanNo = this.paramsData.loanNo;
      headRow.currentDate = this.currentDate;
      reqData.headRow = JSON.stringify(headRow);
      reqData.repayPlanData = JSON.stringify(this.repayPlanData);

      console.log("调用核心导出接口 请求参数：");
      console.log(reqData);

      //调用idp导出功能接口
      // axios({
      //     //url: 'http://10.10.4.71:8000/biz/biz/camel/excelExportToRepayPlan',
      //     url:window.CONFIG.idpServerUrl + '/biz/camel/excelExportToRepayPlan',
      //     method: 'POST',
      //     responseType: 'blob', // 表示服务器响应的数据类型
      //     data:  reqData // 这里是你要发送到后端的数据
      // })
      Axios.post(
        window.CONFIG.idpServerUrl + "/biz/camel/excelExportToRepayPlan",
        reqData,
        { responseType: "blob" }
      )
        .then((response) => {
          if (response.status === 200) {
            // 创建一个Blob URL并创建一个链接元素下载它
            console.log("测试测试");
            console.log(response);
            const blob = new Blob([response.data], {
              type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            });
            const url = window.URL.createObjectURL(blob);
            const link = document.createElement("a");
            link.href = url;
            //let fileName = response.headers['content-disposition'].match(/filename="?(.*)"?(;|$)/)[1]; // 假设后端设置了Content-Disposition
            link.setAttribute("download", "repayPlan.xlsx"); // 通过Content-Disposition获取文件名
            document.body.appendChild(link);
            link.click(); // 触发下载
            window.URL.revokeObjectURL(url); // 释放内存中的URL对象
            document.body.removeChild(link); // 注意清理DOM
          } else {
            // 处理非200状态码的情况
            console.error("Failed to download file:", response.status);
          }
        })
        .catch((error) => {
          console.error("There was an error downloading the file:", error);
        });
    },

    //关闭dialog页面   interestRateData  repayMentData  repayMentStrategy
    handleRepayDialogClose() {
      console.log("关闭dialog页面 ");
      this.repayDialogVisible = false;
      this.paramsData = {};
      this.loanData = {};
      this.interestRateData = {};
      this.repayMentData = {};
      this.repayPlanData = [];
    },
  },
};
</script>

  <style scoped>
.loanInfo .el-col {
  line-height: 30px;
  padding-bottom: 5px;
}
.el-divider {
  margin: 0;
}
.custName {
  color: black;
}
</style>
